<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            客户抱怨分配
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">

        <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
            <ul class="aui-list aui-form-list" style="margin-top: 1%;overflow-y: auto; ">
                <!-- <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width:250px">信息/问题时间</div>
                        <div class="aui-list-item-input" onclick="timePicker();">
                            <input type="text" placeholder="选择日期" class="aui-input" id="informationTime">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width:250px">截至时间</div>
                        <div class="aui-list-item-input" onclick="timePicker2();">
                            <input type="text" placeholder="选择日期" class="aui-input" id="ext06">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">客户</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="客户" id="client" />
                        </div>
                    </div>
                </li>

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">问题发生环节</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="问题发生环节" id="problemOccurs" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">生产单位</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="生产单位" id="productionUnits" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">产品名称</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="产品名称" id="mrlName" />
                        </div>
                        <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectMrlName()"></i>
                    </div>
                </li>

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">产品图号</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="产品图号" id="mrlTuhao" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">产品状态</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="产品状态" id="mrlStatus" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">生产批次</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="生产批次" id="lotCode" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">问题描述</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="问题描述" id="problemDescription" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">问题数量</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="问题数量" id="problemNum" />
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">问题原因类型</div>

                        <div class="aui-list-item-input">
                            <input type="text" placeholder="问题原因类型" id="problemCause" />
                        </div>
                    </div>
                </li> -->
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">部门</div>

                        <div class="aui-list-item-input">
                            <select disabled id="ext03" placeholder="请选择部门" style="font-size: 14px;">
                            </select>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label" style="width: 250px">责任人</div>

                        <div class="aui-list-item-input">
                            <input type="text" disabled placeholder="责任人" id="ext01" />
                        </div>
                        <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectExt01()"></i>
                    </div>
                </li>
            </ul>
            <div style="display: flex;
                         justify-content: space-around;
                         padding-top: 10px;
                         padding-bottom: 10px;">
                <div class="aui-btn aui-btn-info" style="width:30%;margin-top:2%;" onclick="closeWin()">取消
                </div>
                <div class="aui-btn aui-btn-info" style="width:30%;margin-top:2%;" onclick="changeState()">确定
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var ids = "";
    var ext02 = "";//责任人编码
    //初始化
    apiready = function () {
        ids = api.pageParam.ids;
        console.log(ids)
        // $("#informationTime").focus();
        // idSelector = "informationTime";
        //部门下拉框
        doSearchDept()
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }
    //查询详细
    function selectOneSubmitData() {
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem('un');
        var url = serverUrl + "/app/getKmManngerSearchDetail";
        var data = {
            values: {
                un: un,
                id: ids
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    // $("#informationTime").val(list.informationTime);
                    // $("#ext06").val(list.ext06);
                    // $("#client").val(list.client);
                    // $("#problemOccurs").val(list.problemOccurs);
                    // $("#productionUnits").val(list.productionUnits);
                    // $("#mrlName").val(list.mrlName);
                    // $("#mrlTuhao").val(list.mrlTuhao);
                    // $("#mrlStatus").val(list.mrlStatus);
                    // $("#lotCode").val(list.lotCode);
                    // $("#problemDescription").val(list.problemDescription);
                    // $("#problemNum").val(list.problemNum);
                    // $("#problemCause").val(list.problemCause);
                    $("#ext03").val(list.ext03);
                    $("#ext01").val(list.ext01);
                    ext02 = list.ext02;
                    console.log(list.ext03)
                    //失败
                } else if (myobj.code == "1") {

                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }
    function goSelectExt01() {
        //获取部门
        var ext03 = $("#ext03").val();
        if (ext03 == null || ext03 == "" || ext03 == undefined) {
            api.toast({
                msg: '请选择部门！',
                duration: 3000
            });
            return;
        }
        api.openWin({
            name: 'getDutyPerson',
            url: 'getDutyPerson.html',
            pageParam: {
                name: "qckmmanage-assign-detail",
                dept: ext03//部门id
            }
        });
    }
    function goSelectMrlName() {
        api.openWin({
            name: 'selectMrlAndTuhao',
            url: 'selectMrlAndTuhao.html',
            pageParam: {
                name: "qckmmanagesubmitdetail",
            }
        });
    }
    function setMrl(sysid, code, name, drawing) {
        // console.log(111111)
        // console.log(sysid)
        // console.log(name)
        // console.log(drawing)
        $("#mrlName").val(name);
        $("#mrlTuhao").val(drawing);
    }
    function setDutyPerson(sysid, code, name) {
        console.log(1111)
        console.log(name)
        ext02 = code
        console.log(ext02)
        $("#ext01").val(name);
    }
    function doSearchDept() {
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem('un');
        var url = serverUrl + "/app/getDeptNameList";
        var data = {
            values: {
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var map = eval("(" + data + ")");
                var list = eval(map.list);
                var html = "<option value=''>--请选择--</option>";
                for (var i = 0; i < list.length; i++) {
                    html += "<option value='" + list[i].sysid + "'>" + list[i].name + "</option>";
                }
                $api.html($api.byId("ext03"), html);
                if (ids) {
                    //查询详细
                    selectOneSubmitData()
                }
            }
        });
    }

    //时间选择器
    function timePicker() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#informationTime").val(date);
            }
        });
    }

    //时间选择器
    function timePicker2() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#ext06").val(date);
            }
        });
    }

    function changeState(type) {
        // var informationTime = $("#informationTime").val();
        // var ext06 = $("#ext06").val();
        // var client = $("#client").val();
        // var problemOccurs = $("#problemOccurs").val();
        // var productionUnits = $("#productionUnits").val();
        // var mrlName = $("#mrlName").val();
        // var mrlTuhao = $("#mrlTuhao").val();
        // var mrlStatus = $("#mrlStatus").val();
        // var lotCode = $("#lotCode").val();
        // var problemDescription = $("#problemDescription").val();
        // var problemNum = $("#problemNum").val();
        // var problemCause = $("#problemCause").val();
        var ext03 = $("#ext03").val();
        var ext01 = $("#ext01").val();

        // if (informationTime == null || informationTime == "" || informationTime == undefined) {
        //     api.toast({
        //         msg: '信息/问题时间不能为空！',
        //         duration: 3000
        //     });
        //     return;
        // }

        // if (ext06 == null || ext06 == "" || ext06 == undefined) {
        //     api.toast({
        //         msg: '截止时间不能为空！',
        //         duration: 3000
        //     });
        //     return;
        // }


        var un = localStorage.getItem("un");
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/addDataKmMannger";

        api.showProgress({
            title: '保存中...',
        });

        var data = {
            values: {
                // informationTime: informationTime,
                // ext06: ext06,
                // client: client,
                // problemOccurs: problemOccurs,
                // productionUnits: productionUnits,
                // mrlName: mrlName,
                // mrlTuhao: mrlTuhao,
                // mrlStatus: mrlStatus,
                // lotCode: lotCode,
                // problemDescription: problemDescription,
                // problemNum: problemNum,
                // problemCause: problemCause,
                ext03: ext03,
                ext01: ext01,
                ext02: ext02,
                un: un,
                id: ids,
                assignFlag: "2"
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //返回成功
                if (myobj.code == "0") {

                    api.toast({
                        msg: "保存成功",
                        duration: 3000
                    });
                    api.closeWin();
                    api.execScript({
                        name: api.pageParam.name,
                        script: 'dealSuccess()'
                    });

                } else if (myobj.code == "1") {

                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //订单返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

<style>
    .c1 {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 99;
        margin-top: 0%;
    }

    .c2 {
        background-color: white;
        position: fixed;
        width: 400px;
        height: 300px;
        top: 50%;
        left: 50%;
        z-index: 100;
        margin-top: -125px;
        margin-left: -200px;
        padding-top: 2%;
        padding-left: 2%;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    .hide {
        display: none;
    }
</style>

</html>